package ytdp.careagle.com.ytdp.mvp.mode;

import android.content.Context;

import java.util.HashMap;
import java.util.Map;

import ytdp.careagle.com.ytdp.app.G;
import ytdp.careagle.com.ytdp.entity.LoginEntity;
import ytdp.careagle.com.ytdp.entity.SmsCodeIdEntity;
import ytdp.careagle.com.ytdp.net.MyObserver;
import ytdp.careagle.com.ytdp.net.NetWorks;
import ytdp.careagle.com.ytdp.net.Result;

/**
 * Created by admin on 2017/9/12.
 */

public class LoginModel {
    public void goLogin(Context context, String username, String password, MyObserver<Result<LoginEntity>> myObserver) {
        HashMap<String, String> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        NetWorks.getInstance().goLogin(context, map, myObserver);
    }

    public void goLogout(Context context, String password, MyObserver<Result> myObserver) {
        HashMap<String, String> map = new HashMap<>();
        map.put("password", password);
        NetWorks.getInstance().goLogout(context, map, myObserver);
    }

    public void getVerificationCode(Context context, String mobileNumber, final MyObserver<Result<SmsCodeIdEntity>> callback) {
        Map<String, String> header = G.getHeaderNoToken(context);
        HashMap<String, String> map = new HashMap<>();
        map.put("phone", mobileNumber);
        NetWorks.getInstance().getVerificationCode(context, header, map, callback);
    }

    public void resetPassword(Context context, String code, String newPassword, String mobile, final MyObserver<Result> callback) {
        Map<String, String> header = G.getHeaderNoToken(context);
        HashMap<String, String> map = new HashMap<>();
        map.put("phone", mobile + "");
        map.put("code", code);
        map.put("newPassword", newPassword);
        NetWorks.getInstance().resetPassword(context, header, map, callback);
    }

    public void saveCustomer(Context context, Map<String, String> header, String phone, String valuationQueryId, MyObserver<Result> myObserver) {
        HashMap<String, String> map = new HashMap<>();
        map.put("contactPhone", phone + "");
        map.put("valuationQueryId", valuationQueryId);
        NetWorks.getInstance().saveCustomer(context, header, map, myObserver);

    }
}
